{# Copyright The IETF Trust 2021, All Rights Reserved #}
{% load ietf_filters misc_filters tz %}
{# only show if user is secretariat or at least one material is active #}
{% if proceedings_materials|list_extract:1|keep_only:'active' or user|has_role:'Secretariat' %}
    {# Proceedings materials not tied to groups #}
    <h2 class="mt-3" id="proceedings-materials">Proceedings Materials</h2>
    <table class="table table-sm table-striped">
        <thead>
            <tr>
                <th scope="col" data-sort="type">Type</th>
                <th scope="col" data-sort="title">Title</th>
                <th scope="col" data-sort="updated">Updated</th>
            </tr>
        </thead>
        <tbody>
            {% for type_name, material in proceedings_materials %}
                {# secretariat sees empty slots, others do not #}
                {% if user|has_role:'Secretariat' or meeting and material.active %}
                    <tr>
                        <td>{{ type_name }}</td>
                        {% if material and material.active %}
                            <td>
                                <a href="{{ material.get_href }}">{{ material.document.title }}</a>
                            </td>
                            <td>
                                {% with timestamp=material.document.time|utc %}
                                    {{ timestamp|date:"Y-m-d" }}
                                    <br>
                                    <small class="text-body-secondary">{{ timestamp|date:"H:i:s" }} UTC</small>
                                {% endwith %}
                            </td>
                        {% else %}
                            <td colspan="2"></td>
                        {% endif %}
                    </tr>
                {% endif %}
            {% endfor %}
        </tbody>
    </table>

    {% if user|has_role:'Secretariat' %}
        <a class="btn btn-primary"
           href="{% url 'ietf.meeting.views_proceedings.material_details' num=meeting.number %}">
            Edit materials
        </a>
    {% endif %}

{% endif %}